package cn.wh.context.support;

import cn.wh.beans.BeansException;
import cn.wh.beans.factory.ConfigurableListableBeanFactory;
import cn.wh.beans.factory.support.DefaultListableBeanFactory;

public abstract class AbstractRefreshableApplicationContext extends AbstractApplicationContext {

    private DefaultListableBeanFactory beanFactory;

    @Override
    protected void refreshBeanFactory() throws BeansException {
           DefaultListableBeanFactory beanFactory=createBeanFactory();
           loadBeanDefinitions(beanFactory);
           this.beanFactory=beanFactory;
    }



    protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory);

    private DefaultListableBeanFactory createBeanFactory(){
        return new DefaultListableBeanFactory();
    }

    @Override
    protected ConfigurableListableBeanFactory getBeanFactory() {
        return beanFactory;
    }
}
